package uk.co.douglashoskins.weathercompare;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import uk.co.douglashoskins.weathercompare.services.NetQueue;
import uk.co.douglashoskins.weathercompare.ui.MainScreen;

import com.nokia.mid.ui.gestures.GestureInteractiveZone;
import com.nokia.mid.ui.gestures.GestureRegistrationManager;

public class WeatherCompare extends MIDlet {
	public static WeatherCompare m;
	public static Display d;
	public static WeatherCanvas c;
	public static NetQueue n;
	public static int width, height;
	public static boolean NOKIA_TOUCH = false, NOKIA_LOCATION = false;
	public static Font LARGE = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_LARGE);
	public static Font SMALL = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL);
	
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException { }

	protected void pauseApp() { }

	protected void startApp() throws MIDletStateChangeException {
		m = this;
		d = Display.getDisplay(m);
		n = new NetQueue();
		c = new WeatherCanvas();
		c.setFullScreenMode(true);
		GestureRegistrationManager.register(c, new GestureInteractiveZone(GestureInteractiveZone.GESTURE_ALL));
		GestureRegistrationManager.setListener(c, c);
		width = c.getWidth();
		height = c.getHeight();
		d.setCurrent(c);
		Assets.initialise();
		
		try {
			Class.forName("com.nokia.mid.location.LocationUtil");
			NOKIA_LOCATION = true;
		} catch (ClassNotFoundException e) { }
		
		try {
			Class.forName("com.nokia.mid.ui.gestures.GestureEvent");
			NOKIA_TOUCH = true;
		} catch (ClassNotFoundException e) { }
		
		
		ScreenStack.getInstance().push(new MainScreen());
	}
}
